package cn.com.gainfo.bktas.dao;

import java.util.List;

import javax.sql.DataSource;

import cn.com.gainfo.bktas.vo.DepartmentVO;
import cn.yzyue.base.dao.AbstractDAO;
import cn.yzyue.base.log.Log;
import cn.yzyue.base.log.impl.LogImpl;
import cn.yzyue.base.tools.db.DB;
import cn.yzyue.base.tools.db.SQL;
import cn.yzyue.base.vo.VO;

public class DepartmentDAO extends AbstractDAO{

	Log log = new LogImpl();
	
	@Override
	public List find(DataSource dataSource, String sql) {		
		return super.find(dataSource, sql);
	}
	
	@Override
	public boolean add(DataSource dataSource, VO vo) {		
		DepartmentVO dvo = (DepartmentVO) vo;
		String sql = "insert into department(department.deptName) values('"+dvo.getDeptName()+"');";
		return DB.alter(dataSource, sql);		
	}
	
	@Override
	public boolean mod(DataSource dataSource, VO vo) {
		// TODO Auto-generated method stub
		return super.mod(dataSource, vo);
	}
	
	@Override
	public boolean del(DataSource dataSource, String sql) {
		// TODO Auto-generated method stub
		return super.del(dataSource, sql);
	}

	public int checkExists(DataSource dataSource, String deptname) {
		SQL sql = new SQL("select count(*) from department where deptname='"+deptname+"'");		
		return DB.count(dataSource, sql);
	}

	public List getVo(DataSource dataSource, String id) {
		String sql = "select * from department where deptId='"+id+"'";
		return DB.search(dataSource, sql);		
	}
	
}
